var assert = require('assert');
var should = require('should');
var util = require('util');
var zlib = require('zlib');
var _ = require('lodash');
var skillConf = require('../../app/config/skillConf');
var config = require('../config');
var dataApi = require('../../app/libs/dataApi');
var PlayerManager = require('../../app/libs/playerManager');

suite('skillConf', function () {
    var player_manager = new PlayerManager(config.role_id);
    setup(function (done) {
        player_manager.getModel(['task', 'achieve', 'daily_task'], done);
    });

    suite('getSkillLvConf', function () {
        test('获取技能数据正确', function () {
            assert.equal(skillConf.getSkillLvConf(99999, 1) != null, false);

            dataApi.hero_skill_type.each(function (skill_type_conf, key) {
                _.each(skill_type_conf, function (value, skill_type) {
                    assert.equal(skillConf.getSkillLvConf(value.skill_id, 100) != null, false);
                    assert.equal(skillConf.getSkillLvConf(value.skill_id, 1) != null, true);
                });
            });
        });
    });

    suite('判断数据是否正常', function () {
        test('数据正常', function () {
            dataApi.hero_skill_type.each(function (skill_type_conf, key) {
                _.each(skill_type_conf, function (value, skill_type) {
                    var skill_lv_conf = skillConf.getSkillLvConf(value.skill_id, 1);
                    assert.equal(skill_lv_conf.skill_openlvl > 0, true);
                });
            });
        });
    });

    suite('getSkillBufConf', function () {
        test('获取技能附加技能配置', function () {
            var skill_type_conf = dataApi.hero_skill_type.all();
            _.each(skill_type_conf, function (value, skill_type) {
                for (var i = 0; i < 100; i++) {
                    skillConf.getSkillBufConf(skill_type, i);
                };
            });
        });
    });

    suite('所有的子技能类型开启等级必须在技能等级表中能找到', function () {
        test('数据正常', function () {
            var add_skill_type_all_conf = dataApi.add_skill_type.all();
            _.each(add_skill_type_all_conf, function (add_skill_type_conf, skill_id) {
                _.each(add_skill_type_conf, function (value, key) {
                    var need_skill_lv = value.need_skillid_lvl;
                    if (need_skill_lv < 999) {
                        var skill_lv_conf = skillConf.getSkillLvConf(skill_id, need_skill_lv);
                        assert.equal(skill_lv_conf != null, true);
                    }
                });
            });
        });
    });
});
